home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Diamond Collection / The Diamond Collection (Software Vault)(Digital Impact).ISO / cdr48 / 386p_200.zip / 386TIMER.INC < prev    next >
Text File  |  1994-11-02  |  3KB  |  79 lines

  1.        
  2. extrn _InstallTimer:dword
  3. ; Installs timer code
  4.  
  5. extrn _TimerShutDown:dword
  6. ; Kills the timer functions
  7.  
  8. extrn _ReadTimer:dword
  9. ; read the EXACT time tick count down to a 2 microsecond precision
  10. ; in 1193180 Hz cycles  (roughly a little less than a microsecond cycles)
  11. ; edx:eax = 64 bit count
  12.  
  13. extrn _TimerEvent:dword
  14. ; installs a timer event routine into the timer list
  15. ; in: eax=offset of timed routine
  16. ;     edx=timer interval (in 1193180 Hz cycles)
  17. ;     ecx=specific data to load into EDI when the routine eax is called
  18. ; out:
  19. ;       IF carry clear THEN eax=handle of timed routine
  20. ;                      ELSE handles exausted
  21. extrn _TimerSlice:dword
  22. ; changes time interval of a timed routine
  23. ; in: eax=handle of timed routine
  24. ;     edx= new timer interval (in 1193180 Hz cycles)
  25. ; out:
  26. ;     IF carry clear THEN interval changed
  27.  
  28. extrn _Seconds:dword
  29. ; seconds since _InstallTimer has been called
  30.  
  31. extrn _TimerStop:dword
  32. ; Initially set to 1 (timer is stopped)
  33. ; It is set to zero by _InstallTimer
  34. ; and then set back to 1 by _TimerShutDown
  35. ;
  36. ; While running BETWEEN _InstallTimer and _TimerShutDown
  37. ; it is used as a
  38. ; TIMER CRASH FLAG ( 0 = timer ticks good)
  39. ; From time to time, check in the main program if this flag is set to 1
  40. ; (expecially BEFORE using code interacting with timer event functions)
  41. ;
  42. ; If this flag is set to 1, you selected a too high timer frequency
  43. ; and you'd better reinstall the timed event routines
  44. ; using bigger time intervals.
  45. ;
  46. ; Be careful, this flag is turned on only if THE UNINTERRUPTABLE
  47. ; portion of the timer irq handler has overrunned
  48. ; (Jeez! If this happens your cpu is running out of steam!).
  49. ;
  50. ; If this happens, the "automatic protection system" of 386timer
  51. ; kills automatically all the timer events except the "good old" 18.2 Hz
  52. ; timer tick.
  53. ; BUT OVERRUNS CAUSED BY EXECUTION OF TIMED EVENTS ARE NOT DETECTED
  54. ; DIRECTLY (well, you detect them because they "halt" the main program
  55. ; and sooner or later will cause a stack overflow).
  56. ; I choosed not to use automatic detection for them because
  57. ; such a strategy may cause more problems than the one it solve.
  58.  
  59. ; Anyway, look into 386timer to see how i used the 'overrun' flag
  60. ; to detect overruns in the uninterruptable portion of the irq handler.
  61. ; Then use a similar strategy ("inner" flag for overrun detection plus
  62. ; "external" flag for overrun alert) to handle possible overrun
  63. ; situations
  64. ; In the "automatic" overrun detector my only choice
  65. ; was to "kill" the timer, but in other situations it is better
  66. ; to "discard" the last irq with a specific end of interrupt (SEOI).
  67.  
  68. ; Do you fear this is too confusing? Well, it is!
  69. ; But you need overrun detection only in extreme situations.
  70.  
  71. ; My 385/25 can play sound at 8Khz using a timed event but only
  72. ; when running with ms-dos (VCPI), if i run the same program under
  73. ; Windows (DPMI) the fucking slow irq redirection it uses, causes lots
  74. ; of problems and nearly halts the cpu (grrr!).
  75.  
  76. ; So , include overrun detection only in the most cpu intensive
  77. ; or frequency intensive tasks.
  78.  
  79.